package com.wensi.helper

import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.alibaba.android.arouter.launcher.ARouter
import com.wensi.lib_base.BuildConfig

/**
 * ARouter 帮助类
 */
object ARouterHelper {

    // 路由地址，至少要有两级 /xx/xx
    const val PATH_APP_MANAGER = "/app_manager/app_manager_activity"
    const val PATH_CONSTELLATION = "/constellation/constellation_activity"
    const val PATH_DEVELOPER = "/developer/developer_activity"
    const val PATH_JOKE = "/joke/joke_activity"
    const val PATH_MAP = "/map/map_activity"
    const val PATH_SETTING = "/setting/setting_activity"
    const val PATH_VOICE_SETTING = "/voice_setting/voice_setting_activity"
    const val PATH_WEATHER = "/weather/weather_activity"

    // 初始化sdk
    fun initHelper (application: Application) {
        if (BuildConfig.DEBUG) {
            ARouter.openLog()
            ARouter.openDebug()
        }
        ARouter.init(application)
    }

    // 跳转页面
    fun startActivity(path: String) {
        ARouter.getInstance().build(path).navigation()
    }
    fun startActivity(path: String, activity: Activity, requestCode: Int) {
        ARouter.getInstance().build(path).navigation(activity, requestCode)
    }
    // 跳转并携带参数
    fun startActivity(path: String, key: String, value: String) {
        ARouter.getInstance().build(path)
            .withString(key, value)
            .navigation()
    }
    fun startActivity(path: String, key: String, value: Int) {
        ARouter.getInstance().build(path)
            .withInt(key, value)
            .navigation()
    }
    fun startActivity(path: String, key: String, value: Boolean) {
        ARouter.getInstance().build(path)
            .withBoolean(key, value)
            .navigation()
    }
    fun startActivity(path: String, key: String, value: Long) {
        ARouter.getInstance().build(path)
            .withLong(key, value)
            .navigation()
    }
    fun startActivity(path: String, key: String, value: Bundle) {
        ARouter.getInstance().build(path)
            .withBundle(key, value)
            .navigation()
    }
    fun startActivity(path: String, key: String, value: Any) {
        ARouter.getInstance().build(path)
            .withObject(key, value)
            .navigation()
    }
}